﻿using System.Globalization;
using NUnit.Framework;
using ResourceBlender.DAL.Import;

namespace ResourceBlender.Express.Tests.Dal
{
    [TestFixture]
    public class ResxResourceImporterTests
    {
        [TestCase("mypage.aspx.sv-SE.resx", "mypage.aspx", "sv-SE")]
        [TestCase("mypage.aspx.no.resx", "mypage.aspx", "no")]        
        [TestCase("myfile.resx", "myfile", null)]
        [TestCase("myfile.zh-Hans.resx", "myfile", "zh-Hans")]
        [TestCase("myfile.that.has.many.dots.en.resx", "myfile.that.has.many.dots", "en")]
        [TestCase("page.aspx.resx", "page.aspx", null)]
        [TestCase("page.aspx.en-US.resx", "page.aspx", "en-US")]
        public void Test(string fileName, string expectedBundleName, string expectedCultureName)
        {
            bool result;

            string bundleName;
            CultureInfo cultureInfo = ResxResourceImporter.GetCultureFromFileName(fileName, out bundleName);

            if (cultureInfo != null)
            {
                result = expectedBundleName.Equals(bundleName) && expectedCultureName.Equals(cultureInfo.Name);
            } else
            {
                result = expectedBundleName.Equals(bundleName) && expectedCultureName == null;
            }

            Assert.True(result);
        }
    }
}